package com.cheung.leetcode.arr;

import  org.junit.jupiter.api.Test;

import java.util.Arrays;

/**
 * @BelongsProject : java-leetcode
 * @BelongsPackage : com.cheung.leetcode.arr
 * @Author :  cheungming
 * @CreateTime : 2024-07-23 08:44:25
 * @Description : 274 H-Index
 * @Version : 1.0
 */
public class Code274Test {

    public int hIndex(int[] citations) {
        Arrays.sort(citations);
        int h = 0, i = citations.length - 1;
        while (i >= 0 && citations[i] > h) {
            h++;
            i--;
        }
        return h;
    }

    @Test
    public void test1() {
        assert hIndex(new int[]{3, 0, 6, 1, 5}) == 3;
    }
}
